package com.iminutes.controller;

import com.iminutes.service.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description TODO
 * @Author liyuhua
 * @Date 2021/8/4 16:12
 **/
public class IndexController {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        //当scope=“prototype”时，spring容器要创建同一类型的多个对象，init方法在每个对象创建时均执行一次
/*        UserService us1 = (UserService) context.getBean("userService1");
        UserService us2 = (UserService) context.getBean("userService2");*/
        //当scope=“singleton”时，关闭容器会导致bean实例的销毁，调用destroy方法一次
        //context.close();

        //当scope=“prototype”时，对象的销毁由垃圾回收机制gc()控制，destroy方法将不会被执行
        UserService us1 = (UserService) context.getBean("userService1");
        UserService us2 = (UserService) context.getBean("userService2");
    }
}
